<?php
namespace Home\Model;
use Think\Model;
/**
 * Created by PhpStorm.
 * User: 97628
 * Date: 2016/6/19
 * Time: 12:37
 */
class usercollectionModel extends Model{
    /**
     * 得到收藏列表
     * @param $openid string
     * @return array [Id, title, author, answerId]
     */
    function getCollection($openid){
        $condition['openid'] = $openid;
        $res = M('usercollection')->where($condition)->order('Id desc')->getField('Id, answerId');
        $list = [];
        foreach($res as $k=>$answerId){
            $data = D('zhihu')->getPreview($answerId);
            array_push($list, $data);
        }
        return $list;
    }

}